public class TestLoop2{
	
	public static void main(String [] args){
		final int MAX = 1000;
		final int MIN = 10;
		int num = 0;
		int counter = 0;
		do{
			num = (int)(Math.random()*(MAX - MIN+1)+MIN);
			counter++;
		}while(num%3!=0|| num %8!=0||num%7!=0);
		System.out.println("num="+num);
		System.out.println("counter="+counter);
	}
}